//
// Created by mac on 1/26/22.
//

#include <string>
using namespace std;
int lengthOfLastWord(string s) {
    if (s.length() == 0) return 0;

    int end = s.length() - 1;
    while (end >= 0 && s[end] == ' ') end--;
    if (end < 0) return 0;

    int start = end;
    while (start >= 0 && s[start] != ' ') start--;

    return end - start;


}